<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Does Boost.Python work with Mac OS X?</title>
<link rel="stylesheet" href="../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Boost.Python">
<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
<link rel="prev" href="why_doesn_t_my_operator_work.html" title="Why doesn't my *= operator work?">
<link rel="next" href="how_can_i_find_the_existing_pyob.html" title="How can I find the existing PyObject that holds a C++ object?">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="why_doesn_t_my_operator_work.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_find_the_existing_pyob.html"><img src="../images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="faq.does_boost_python_work_with_mac_"></a><a class="link" href="does_boost_python_work_with_mac_.html" title="Does Boost.Python work with Mac OS X?">Does Boost.Python
      work with Mac OS X?</a>
</h3></div></div></div>
<p>
        It is known to work under 10.2.8 and 10.3 using Apple's gcc 3.3 compiler:
      </p>
<pre class="programlisting"><span class="identifier">gcc</span> <span class="special">(</span><span class="identifier">GCC</span><span class="special">)</span> <span class="number">3.3</span> <span class="number">20030304</span> <span class="special">(</span><span class="identifier">Apple</span> <span class="identifier">Computer</span><span class="special">,</span> <span class="identifier">Inc</span><span class="special">.</span> <span class="identifier">build</span> <span class="number">1493</span><span class="special">)</span></pre>
<p>
        Under 10.2.8 get the August 2003 gcc update (free at <a href="http://connect.apple.com" target="_top">http://connect.apple.com</a>).
        Under 10.3 get the Xcode Tools v1.0 (also free).
      </p>
<p>
        Python 2.3 is required. The Python that ships with 10.3 is fine. Under 10.2.8
        use these commands to install Python as a framework:
      </p>
<pre class="programlisting"><span class="special">./</span><span class="identifier">configure</span> <span class="special">--</span><span class="identifier">enable</span><span class="special">-</span><span class="identifier">framework</span>
<span class="identifier">make</span>
<span class="identifier">make</span> <span class="identifier">frameworkinstall</span></pre>
<p>
        The last command requires root privileges because the target directory is
        <code class="computeroutput"><span class="special">/</span><span class="identifier">Library</span><span class="special">/</span><span class="identifier">Frameworks</span><span class="special">/</span><span class="identifier">Python</span><span class="special">.</span><span class="identifier">framework</span><span class="special">/</span><span class="identifier">Versions</span><span class="special">/</span><span class="number">2.3</span></code>. However,
        the installation does not interfere with the Python version that ships with
        10.2.8.
      </p>
<p>
        It is also crucial to increase the <code class="computeroutput"><span class="identifier">stacksize</span></code>
        before starting compilations, e.g.:
      </p>
<pre class="programlisting"><span class="identifier">limit</span> <span class="identifier">stacksize</span> <span class="number">8192</span><span class="identifier">k</span></pre>
<p>
        If the <code class="computeroutput"><span class="identifier">stacksize</span></code> is too small
        the build might crash with internal compiler errors.
      </p>
<p>
        Sometimes Apple's compiler exhibits a bug by printing an error like the following
        while compiling a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">your_type</span><span class="special">&gt;</span></code>
        template instantiation:
      </p>
<pre class="programlisting"><span class="special">.../</span><span class="identifier">inheritance</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">:</span><span class="number">44</span><span class="special">:</span> <span class="identifier">error</span><span class="special">:</span> <span class="identifier">cannot</span>
  <span class="keyword">dynamic_cast</span> <span class="error">`</span><span class="identifier">p</span><span class="char">' (of type `struct cctbx::boost_python::&lt;unnamed&gt;::add_pair*
  '</span><span class="special">)</span> <span class="identifier">to</span> <span class="identifier">type</span> <span class="error">`</span><span class="keyword">void</span><span class="special">*</span><span class="error">'</span> <span class="special">(</span><span class="identifier">source</span> <span class="identifier">type</span> <span class="identifier">is</span> <span class="keyword">not</span> <span class="identifier">polymorphic</span><span class="special">)</span>
</pre>
<p>
        We do not know a general workaround, but if the definition of <code class="computeroutput"><span class="identifier">your_type</span></code> can be modified the following
        was found to work in all cases encountered so far:
      </p>
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">your_type</span>
<span class="special">{</span>
  <span class="comment">// before defining any member data</span>
<span class="preprocessor">#if</span> <span class="identifier">defined</span><span class="special">(</span><span class="identifier">__MACH__</span><span class="special">)</span> <span class="special">&amp;</span><span class="identifier">amp</span><span class="special">;&amp;</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">defined</span><span class="special">(</span><span class="identifier">__APPLE_CC__</span><span class="special">)</span> <span class="special">&amp;</span><span class="identifier">amp</span><span class="special">;&amp;</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">__APPLE_CC__</span> <span class="special">==</span> <span class="number">1493</span>
  <span class="keyword">bool</span> <span class="identifier">dummy_</span><span class="special">;</span>
<span class="preprocessor">#endif</span>
  <span class="comment">// now your member data, e.g.</span>
  <span class="keyword">double</span> <span class="identifier">x</span><span class="special">;</span>
  <span class="keyword">int</span> <span class="identifier">j</span><span class="special">;</span>
  <span class="comment">// etc.</span>
<span class="special">};</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
      Abrahams, Stefan Seefeld<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="why_doesn_t_my_operator_work.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_find_the_existing_pyob.html"><img src="../images/next.png" alt="Next"></a>
</div>
</body>
</html>
